---
sidebar_position: 4
title: Adding memory
hide_table_of_contents: true
---

# Adding memory

This shows how to add memory to an arbitrary chain. Right now, you can use the memory classes but need to hook them up manually.

<details>
  <summary>Interactive tutorial</summary>
  The screencast below interactively walks through an example of memory management.
  You can update and run the code as it's being written in the video!
  <iframe
    src="https://scrimba.com/scrim/co5e543df81e00a694786d0c7?embed=langchain,mini-header"
    width="100%"
    height="600px"
  ></iframe>
</details>

import CodeBlock from "@theme/CodeBlock";
import MemoryExample from "@examples/guides/expression_language/cookbook_memory.ts";

import IntegrationInstallTooltip from "@mdx_components/integration_install_tooltip.mdx";

<IntegrationInstallTooltip></IntegrationInstallTooltip>

```bash npm2yarn
npm install @langchain/anthropic
```

<CodeBlock language="typescript">{MemoryExample}</CodeBlock>
